﻿using System;
using System.Net;
using System.Xml.Linq;
using System.Linq;

namespace ArmoryBrowser.Entities
{
    public class Melee
    {
        #region Fields
        private WeaponDamage _mainHandDamageField;
        private WeaponDamage _offHandDamageField;
        private WeaponSpeed _mainHandSpeedField;
        private WeaponSpeed _offHandSpeedField;
        private Power _powerField;
        private HitRating _hitRatingField;
        private CritChance _critChanceField;
        private Expertise _expertiseField;
        #endregion
        #region Properties
        public WeaponDamage MainHandDamage
        {
            get
            {
                return this._mainHandDamageField;
            }
            set
            {
                this._mainHandDamageField = value;
            }
        }

        public WeaponDamage OffHandDamage
        {
            get
            {
                return this._offHandDamageField;
            }
            set
            {
                this._offHandDamageField = value;
            }
        }

        public WeaponSpeed MainHandSpeed
        {
            get
            {
                return this._mainHandSpeedField;
            }
            set
            {
                this._mainHandSpeedField = value;
            }
        }

        public WeaponSpeed OffHandSpeed
        {
            get
            {
                return this._offHandSpeedField;
            }
            set
            {
                this._offHandSpeedField = value;
            }
        }

        public Power Power
        {
            get
            {
                return this._powerField;
            }
            set
            {
                this._powerField = value;
            }
        }

        public HitRating HitRating
        {
            get
            {
                return this._hitRatingField;
            }
            set
            {
                this._hitRatingField = value;
            }
        }

        public CritChance CritChance
        {
            get
            {
                return this._critChanceField;
            }
            set
            {
                this._critChanceField = value;
            }
        }

        public Expertise Expertise
        {
            get
            {
                return this._expertiseField;
            }
            set
            {
                this._expertiseField = value;
            }
        }
        #endregion
        #region Constructor
        public Melee(XElement element)
        {
            MainHandDamage = element.Elements("mainHandDamage").Select(e => new WeaponDamage(e)).FirstOrDefault();
            OffHandDamage = element.Elements("offHandDamage").Select(e => new WeaponDamage(e)).FirstOrDefault();
            MainHandSpeed = element.Elements("mainHandSpeed").Select(e => new WeaponSpeed(e)).FirstOrDefault();
            OffHandSpeed = element.Elements("offHandSpeed").Select(e => new WeaponSpeed(e)).FirstOrDefault();
            Power = element.Elements("power").Select(e => new Power(e)).FirstOrDefault();
            HitRating = element.Elements("hitRating").Select(e => new HitRating(e)).FirstOrDefault();
            CritChance = element.Elements("critChance").Select(e => new CritChance(e)).FirstOrDefault();
            Expertise = element.Elements("expertise").Select(e => new Expertise(e)).FirstOrDefault();
        }
        #endregion
    }
}
